package cn.tsinghua.comsmacitccntsinghua.boardconfig;

import android.content.Context;
import android.util.Log;

import cn.Port.myserialport.PortSend;
import cn.Port.myserialport.SerialPortUtil;
import cn.Port.myserialport.controll.BoardController;
import cn.tsinghua.comsmacitccntsinghua.bean.BaseDataInfo;
import cn.tsinghua.comsmacitccntsinghua.utils.StringUtil;

/**
 * 监测垃圾箱状态
 * 1. 获取投口总重
 * 2. 投口状态
 * 3. 箱内温度
 * 4. 查询溢满状态
 * 9. 警报信息
 * 10. 电机异常
 */
public class DustbinStatusControl {
    private Context context;
    private BaseDataInfo.DataBean.DeviceBean device;
    private BoardController boardController;

    private Integer loginTime = 0;

    public static final String TAG = "DustbinStatusControl";

    public DustbinStatusControl(Context context, BoardController mBoardController) {
        this.context = context;
        this.boardController = mBoardController;
    }

    //通知底层登录成功
    public String  loginNotice(){
        SerialPortUtil serialPortUtil = new SerialPortUtil();
        serialPortUtil.openSerialPort(5);
        serialPortUtil.sendSerialPort(PortSend.userLogin);
        Log.d(TAG,"用户登录" );
        loginTime++;
        Log.d(TAG,"loginTime " + loginTime);
        return "20000";
    }

    //通知底层退出登录成功
    public void logOutNotice(){
        Log.d(TAG,"用户退出登录" );
        loginTime--;
        Log.d(TAG,"loginTime " + loginTime);
        boardController.userLogout();
    }
    //发送重量
    public void weigh(){
        boardController.getMouthWeight();
    }
    //获取板子ID
    public String getBoardId(){
        return boardController.getBoardId();
    }

}
